﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class Employee_HRViewVacancyDetails : System.Web.UI.Page
{
    EmployeeMethord EM = new EmployeeMethord();
    string VacancyID = "";
    string UserName = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            UserName = Session["User"].ToString();
            VacancyID = Request.QueryString["ID"].ToString();
            LoadData(VacancyID);
        }
        catch (Exception ex)
        {
            Console.Write(ex.Message);
        }
    }
    private void LoadData(string _ID)
    {
        DataTable tb = EM.ReturnInformationVacancy(VacancyID, UserName);
        if (tb.Rows.Count > 0)
        {
            txtVacancyID.Text = tb.Rows[0]["VacancyID"].ToString();
            txtTitle.Text = tb.Rows[0]["Title"].ToString();
            txtJobID.Text = EM.ReturnNameJobType(Convert.ToInt32(tb.Rows[0]["JobID"].ToString()));
            txtDescription.Text = tb.Rows[0]["Description"].ToString();
            txtNumberOfJob.Text = tb.Rows[0]["NumberOfJob"].ToString();
            txtNumberEmpty.Text = tb.Rows[0]["NumberEmpty"].ToString();
            txtSalary.Text = tb.Rows[0]["Salary"].ToString();
            txtWorkplace.Text = tb.Rows[0]["Workplace"].ToString();
            txtDateCreatioin.Text = tb.Rows[0]["DateCreatioin"].ToString().Substring(0, tb.Rows[0]["DateCreatioin"].ToString().IndexOf(" "));
            txtDateFulfilled.Text = tb.Rows[0]["DateFulfilled"].ToString().Substring(0, tb.Rows[0]["DateFulfilled"].ToString().IndexOf(" "));
            switch(Convert.ToInt32(tb.Rows[0]["Status"].ToString()))
            {
                case 1:
                    txtStatus.Text = "Open";
                    break;
                case 2:
                    txtStatus.Text = "Suspended";
                    break;
                case 3:
                    txtStatus.Text = "Close";
                    break;
            }
            lbtnChange.PostBackUrl = "ChangeVacancy.aspx?ID="+txtVacancyID.Text;
        }
    }
}